Repository navigation
[INFRA-746] Run two nginx worker processes - #33
Conversation
worker_processes auto starts one worker per CPU it can see, and it does not read the container's CPU limit. As a sidecar on an 8-core node with a 100m limit, eight workers and their aio threads share a 10ms-per-100ms quota and are throttled together on start-up and bursts. Two workers with 8000 connections each are plenty for a per-pod proxy. A deployment that needs more can still mount its own main.conf.
There was a problem hiding this comment.
Looks good to me. worker_processes auto only counts the node's CPUs, so pinning it to 2 makes sense for the sidecar. I checked our sidecar deployments and they all run with a small CPU limit and don't override main.conf, so they'll pick this up cleanly.
A couple of small things (non-blocking):
- Capacity note: a proxied request uses two file descriptors, and
worker_rlimit_nofileis 8192. So each worker tops out around 4k connections, not 8k. Still plenty. - README: the core config example still shows
worker_processes auto;.
Same issue elsewhere (FYI): a few of our apps run their own nginx with worker_processes auto; and a small CPU limit, so they'll hit the same throttling. This PR doesn't reach them, but it's a one-line fix in each of their configs. Happy to share the list.
Idea for later: the upstream nginx image has a script that sets the worker count from the container's CPU limit. It can't edit our main.conf as it stands. A small entrypoint script could write the value to /tmp, and main.conf could include it. Then each deployment would size itself automatically.
Pins nginx to two worker processes instead of
auto, so the proxy no longer starts one worker per node CPU when it runs as a sidecar with a small CPU limit.Motivation
worker_processes autocounts the CPUs nginx can see and does not read the container's CPU limit. On an 8-core node the proxy starts eight workers, each with its ownaio threadspool, alongside the OTel exporter. Under a100mlimit they all share 10ms of CPU per 100ms period, so start-up and short bursts spend the quota in a few milliseconds and requests wait for the next period. Two workers atworker_connections 8000each are far more than a per-pod proxy needs.Changes
config/main.confsetsworker_processes 2;.1.31.9-1changelog entry.Risk
/etc/nginx/main.conf, as the README describes.1.31.9-1, so rollback is keeping or restoring1.31.9there.Testing
nginx -Tin the image should showworker_processes 2;, andpsshould list twonginx: worker processentries.Rollout
1.31.9-1to publish the image.nginx-proxytag in Shipyard's sidecar builder to1.31.9-1.References